<html>
<head><meta charset="utf-8"><title>How does rust-analyzer&#x27;s vscode extenstion handle debugging? · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/How.20does.20rust-analyzer&#x27;s.20vscode.20extenstion.20handle.20debugging.3F.html">How does rust-analyzer&#x27;s vscode extenstion handle debugging?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="247139816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/How%20does%20rust-analyzer%27s%20vscode%20extenstion%20handle%20debugging%3F/near/247139816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> sim <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/How.20does.20rust-analyzer&#x27;s.20vscode.20extenstion.20handle.20debugging.3F.html#247139816">(Jul 25 2021 at 19:02)</a>:</h4>
<p>I was trying to add debugging support to <a href="https://github.com/simrat39/rust-tools.nvim/">https://github.com/simrat39/rust-tools.nvim/</a> but was a bit confused on how ra's vscode extension handles debugging in the code lenses/hover actions. So the hover actions gives a cargo command, do i run it and somehow get the path to the debug binary? i tried looking at the vscode extension code but its a bit confusing</p>



<a name="247140591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/How%20does%20rust-analyzer%27s%20vscode%20extenstion%20handle%20debugging%3F/near/247140591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> sim <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/How.20does.20rust-analyzer&#x27;s.20vscode.20extenstion.20handle.20debugging.3F.html#247140591">(Jul 25 2021 at 19:21)</a>:</h4>
<p>ok so i --message-format=json then parse it to get the binary?</p>



<a name="247182352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/How%20does%20rust-analyzer%27s%20vscode%20extenstion%20handle%20debugging%3F/near/247182352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/How.20does.20rust-analyzer&#x27;s.20vscode.20extenstion.20handle.20debugging.3F.html#247182352">(Jul 26 2021 at 09:51)</a>:</h4>
<p>That's complicated, and, tbh, I don't really know a lot about this.</p>



<a name="247182550"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/How%20does%20rust-analyzer%27s%20vscode%20extenstion%20handle%20debugging%3F/near/247182550" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/How.20does.20rust-analyzer&#x27;s.20vscode.20extenstion.20handle.20debugging.3F.html#247182550">(Jul 26 2021 at 09:53)</a>:</h4>
<p>My understanding is we don't acctually implement debugging ourselves, we just out-source it to two other extensions:</p>
<p><a href="https://github.com/rust-analyzer/rust-analyzer/blob/35e072ed44c55e5c74640fe7ab3aeffe20306d2a/editors/code/src/debug.ts#L63-L67">https://github.com/rust-analyzer/rust-analyzer/blob/35e072ed44c55e5c74640fe7ab3aeffe20306d2a/editors/code/src/debug.ts#L63-L67</a></p>



<a name="247183297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/How%20does%20rust-analyzer%27s%20vscode%20extenstion%20handle%20debugging%3F/near/247183297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/How.20does.20rust-analyzer&#x27;s.20vscode.20extenstion.20handle.20debugging.3F.html#247183297">(Jul 26 2021 at 10:02)</a>:</h4>
<p>And yeah, one fundamental problem there is that cargo really like when you run the stuff via <code>cargo run</code> or <code>cargo test</code>, and <code>lldb -- cargo test</code> won't do the right thing. </p>
<p>So we also run <code>cargo build</code> / <code>cargo test --no-run</code> before that, with <code>--message-format=json</code>, to learn where the binary is, and pass that directly to the debugger</p>



<a name="247183314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/How%20does%20rust-analyzer%27s%20vscode%20extenstion%20handle%20debugging%3F/near/247183314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/How.20does.20rust-analyzer&#x27;s.20vscode.20extenstion.20handle.20debugging.3F.html#247183314">(Jul 26 2021 at 10:02)</a>:</h4>
<p><span aria-label="thinking" class="emoji emoji-1f914" role="img" title="thinking">:thinking:</span> I wonder if we use <code>CARGO_RUNER</code> instead for that?</p>



<a name="247384207"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/How%20does%20rust-analyzer%27s%20vscode%20extenstion%20handle%20debugging%3F/near/247384207" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> sim <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/How.20does.20rust-analyzer&#x27;s.20vscode.20extenstion.20handle.20debugging.3F.html#247384207">(Jul 27 2021 at 20:08)</a>:</h4>
<p>Yup I did that and debugging works perfectly fine, just have to give a message that compilation might take some time</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>